package com.example.demo.controller.layuiController;

import com.example.demo.service.SynRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @需求描述:增量(全量)数据同步
 * @创建人:whh
 * @创建时间: 2020/6/15
 * @修改需求:
 * @修改人:
 * @修改时间:
 * @需求思路:
 */
@Controller
@RequestMapping("/synData")
public class synDataController {

    @Autowired
    private SynRecordService recordService;

    @RequestMapping(value = "/goManualAddSyn",method = RequestMethod.GET)
    public String gomManualAddSyn(HttpServletRequest request){

        return "synData/manualAddSyn";
    }


    @RequestMapping(value = "/goManualAllSyn",method = RequestMethod.GET)
    public String gomManualAllSyn(HttpServletRequest request){

        return "synData/manualAllSyn";
    }



    @RequestMapping(value = "/goTaskAddSyn",method = RequestMethod.GET)
    public String goTaskAddSyn(HttpServletRequest request){

        return "synData/taskAddSyn";
    }



    @RequestMapping(value = "/goTaskAllSyn",method = RequestMethod.GET)
    public String goTaskAllSyn(HttpServletRequest request){
        return "synData/taskAllSyn";

    }


    @RequestMapping(value = "/goManualSynRecord",method = RequestMethod.GET)
    public String goManualSynRecord(HttpServletRequest request){
        return "synRecord/manualSynRecord";

    }

    /**
     * 增量同步记录统计页面跳转
     * @author   whh
     * @param
     * @return      java.lang.String
     * @exception
     * @date        2020/6/22 15:31
     */
    @RequestMapping("/goAddSynStatistics")
    public String addSynStatistics(){

        return "/synStatistics/addSynStatistics";
    }


    /**
     * 全量同步记录统计页面跳转
     * @author   whh
     * @param
     * @return      java.lang.String
     * @exception
     * @date        2020/6/22 15:31
     */
    @RequestMapping("/goAllSynStatistics")
    public String allSynStatistics(){

        return "/synStatistics/allSynStatistics";
    }

    @RequestMapping(value = "/goManualAllSynRecord",method = RequestMethod.GET)
    public String goManualAllSynRecord(HttpServletRequest request){
        return "synRecord/manualAllSynRecord";

    }


    /**
     * 增量同步监控记录
     * @author   whh
     * @param request
     * @return      java.util.Map
     * @exception
     * @date        2020/6/16 10:30
     */
    @ResponseBody
    @RequestMapping(value = "/getSynRecord",method = RequestMethod.POST)
    public Map getSynRecord(HttpServletRequest request ){

        String synType = request.getParameter("synType");     //同步类型 1 增量 2 全量
        String page = request.getParameter("page");     //当前页
        String limit = request.getParameter("limit");   //每页显示记录数

        return this.recordService.findAllSynRecord(synType,page,limit);
    }


    @ResponseBody
    @RequestMapping(value = "/getSynStatistics")
    public Map getSynStatistics(HttpServletRequest request){
        String synType = request.getParameter("synType");     //同步类型 1 增量 2 全量
        String page = request.getParameter("page");     //当前页
        String limit = request.getParameter("limit");   //每页显示记录数
        return this.recordService.getSynStatistics(synType,page,limit);
    }

}
